<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width",
          initial-scale="1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>垂直居中第二种实现方案</title>
    <style>
        #parent {
            width: 200px;
            height: 600px;
            background: #ccc;
            position: relative;
        }
        #child {
            width: 200px;
            height: 200px;
            background: #c9394a;
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
        }
    </style>
</head>
<body>
<div id="parent">
    <div id="child"></div>
</div>

</body>
</html>